package com.wkbb.basic.thread;

import com.wkbb.basic.service.UserOpenService;
import lombok.extern.slf4j.Slf4j;

/**
 * @author dengjingyuan
 * @date 2019-12-05 16:49
 */
@Slf4j
public class BacisDeleteAddressBookKeyTask implements Runnable {

    private Long userId;

    private Integer type;

    private Long orgId;

    private UserOpenService userOpenService;

    public BacisDeleteAddressBookKeyTask(Long userId, Integer type, Long orgId, UserOpenService userOpenService) {
        this.userId = userId;
        this.type = type;
        this.orgId = orgId;
        this.userOpenService = userOpenService;

    }

    public BacisDeleteAddressBookKeyTask() {

    }

    //删除和用户相关的通讯录缓存(type:2:家长通讯录,3:老师通讯录,1园长通讯录)
    @Override
    public void run() {
        log.info("*******BasicTask**********userId:{},type:{},orgId:{},userOpenService:{}", userId, type, orgId, userOpenService);
        try {
             /*
              * 当存在批量修改数据的时候（特别是导入数据），班级里面的其他用户会被重复调用删除通讯录缓存接口。
              * 只能在批量操作数据的时候不去处理通讯录缓存，导入完成后再去批量清理整个学校的通讯录缓存。
              * **/
            userOpenService.deleteRedisAddressBookKey(userId, type, orgId);
        } catch (Exception e) {
            log.error("*******BasicTask**********:{}", e.getMessage());
        }
    }
}